export const initialProductList = [
    {
    id:1,
    productName: '华为Mate手机',
    description: '这是一个手机，属于华为',
    category: '2.2',
    price: 3690,
    stock: 50,
    views: 1200,
    sales: 300,
    parameters: ['购买类型: 暗夜黑 256G', '优惠券: 暂无', '促销活动: 暂无'],
    services: ['七天无理由退货' , '退货运费险'],
    reviews: 4.5,
        details: [
            'https://cdn.cnbj1.fds.api.mi-img.com/product-images/xiaomi14ghnegm/index/23234.png',
            'https://cdn.cnbj1.fds.api.mi-img.com/product-images/xiaomi14ghnegm/index/40717.png',
            'https://cdn.cnbj1.fds.api.mi-img.com/product-images/xiaomi14ghnegm/index/23203.png',
            'https://cdn.cnbj1.fds.api.mi-img.com/product-images/xiaomi14ghnegm/index/28955-2.png',
            'https://cdn.cnbj1.fds.api.mi-img.com/product-images/xiaomi14ghnegm/index/37138.png',
        ],
    userReviews: [
        {
            avatar: 'https://q9.itc.cn/q_70/images03/20240509/ed6fba708e1748e9a33e59be848515ee.jpeg',
            name: '张三',
            comment: '商品质量很好，非常满意！',
            rating: 5,
        },
        {
            avatar: 'https://q4.itc.cn/q_70/images03/20240521/47eb5d9a8b37454aaf2bc5d4e3c16c75.jpeg',
            name: '李四',
            comment: '发货速度很快，但包装有待改进。',
            rating: 4,
        },
    ],
},
    {
        id:2,
        productName: '小米13手机 徕卡光学镜头',
        description: '全网通5G小米旗舰新品',
        category: '2.1',
        price: 3065,
        stock: 60,
        views: 1500,
        sales: 400,
        parameters: ['购买类型: 黑色 128G', '优惠券: 暂无', '促销活动: 暂无'],
        services: ['七天无理由退货' , '退货运费险'],
        reviews: 4.5,
        details: [
            'https://cdn.cnbj1.fds.api.mi-img.com/product-images/xiaomi14ghnegm/index/23234.png',
            'https://cdn.cnbj1.fds.api.mi-img.com/product-images/xiaomi14ghnegm/index/40717.png',
            'https://cdn.cnbj1.fds.api.mi-img.com/product-images/xiaomi14ghnegm/index/23203.png',
            'https://cdn.cnbj1.fds.api.mi-img.com/product-images/xiaomi14ghnegm/index/28955-2.png',
            'https://cdn.cnbj1.fds.api.mi-img.com/product-images/xiaomi14ghnegm/index/37138.png',
        ],
        userReviews: [
            {
                avatar: 'https://q9.itc.cn/q_70/images03/20240509/ed6fba708e1748e9a33e59be848515ee.jpeg',
                name: '张三',
                comment: '商品质量很好，非常满意！',
                rating: 5,
            },
            {
                avatar: 'https://q4.itc.cn/q_70/images03/20240521/47eb5d9a8b37454aaf2bc5d4e3c16c75.jpeg',
                name: '李四',
                comment: '发货速度很快，但包装有待改进。',
                rating: 4,
            },
        ],
    },
    {
        id:3,
        productName: '小米Note13 Pro',
        description: '小米新品手机',
        category: '2.1',
        price: 2580,
        stock: 60,
        views: 1500,
        sales: 400,
        parameters: ['购买类型: 黑色 128G', '优惠券: 暂无', '促销活动: 暂无'],
        services: ['七天无理由退货' , '退货运费险'],
        reviews: 4.5,
        details: [
            'https://cdn.cnbj1.fds.api.mi-img.com/product-images/xiaomi14ghnegm/index/23234.png',
            'https://cdn.cnbj1.fds.api.mi-img.com/product-images/xiaomi14ghnegm/index/40717.png',
            'https://cdn.cnbj1.fds.api.mi-img.com/product-images/xiaomi14ghnegm/index/23203.png',
            'https://cdn.cnbj1.fds.api.mi-img.com/product-images/xiaomi14ghnegm/index/28955-2.png',
            'https://cdn.cnbj1.fds.api.mi-img.com/product-images/xiaomi14ghnegm/index/37138.png',
        ],
        userReviews: [
            {
                avatar: 'https://q9.itc.cn/q_70/images03/20240509/ed6fba708e1748e9a33e59be848515ee.jpeg',
                name: '张三',
                comment: '商品质量很好，非常满意！',
                rating: 5,
            },
            {
                avatar: 'https://q4.itc.cn/q_70/images03/20240521/47eb5d9a8b37454aaf2bc5d4e3c16c75.jpeg',
                name: '李四',
                comment: '发货速度很快，但包装有待改进。',
                rating: 4,
            },
        ],
    },
    {
        id:4,
        productName: '小米Redmi K70',
        description: '第二代骁龙8处理器',
        category: '2.1',
        price: 1857,
        stock: 60,
        views: 1500,
        sales: 400,
        parameters: ['购买类型: 黑色 128G', '优惠券: 暂无', '促销活动: 暂无'],
        services: ['七天无理由退货' , '退货运费险'],
        reviews: 4.5,
        details: [
            'https://cdn.cnbj1.fds.api.mi-img.com/product-images/xiaomi14ghnegm/index/23234.png',
            'https://cdn.cnbj1.fds.api.mi-img.com/product-images/xiaomi14ghnegm/index/40717.png',
            'https://cdn.cnbj1.fds.api.mi-img.com/product-images/xiaomi14ghnegm/index/23203.png',
            'https://cdn.cnbj1.fds.api.mi-img.com/product-images/xiaomi14ghnegm/index/28955-2.png',
            'https://cdn.cnbj1.fds.api.mi-img.com/product-images/xiaomi14ghnegm/index/37138.png',
        ],
        userReviews: [
            {
                avatar: 'https://q9.itc.cn/q_70/images03/20240509/ed6fba708e1748e9a33e59be848515ee.jpeg',
                name: '张三',
                comment: '商品质量很好，非常满意！',
                rating: 5,
            },
            {
                avatar: 'https://q4.itc.cn/q_70/images03/20240521/47eb5d9a8b37454aaf2bc5d4e3c16c75.jpeg',
                name: '李四',
                comment: '发货速度很快，但包装有待改进。',
                rating: 4,
            },
        ],
    },
    {
        id:5,
        productName: '小米Redmi Turbo3',
        description: '第三代骁龙8s 新品5G手机',
        category: '2.1',
        price: 1491,
        stock: 60,
        views: 1500,
        sales: 400,
        parameters: ['购买类型: 黑色 128G', '优惠券: 暂无', '促销活动: 暂无'],
        services: ['七天无理由退货' , '退货运费险'],
        reviews: 4.5,
        details: [
            'https://cdn.cnbj1.fds.api.mi-img.com/product-images/xiaomi14ghnegm/index/23234.png',
            'https://cdn.cnbj1.fds.api.mi-img.com/product-images/xiaomi14ghnegm/index/40717.png',
            'https://cdn.cnbj1.fds.api.mi-img.com/product-images/xiaomi14ghnegm/index/23203.png',
            'https://cdn.cnbj1.fds.api.mi-img.com/product-images/xiaomi14ghnegm/index/28955-2.png',
            'https://cdn.cnbj1.fds.api.mi-img.com/product-images/xiaomi14ghnegm/index/37138.png',
        ],
        userReviews: [
            {
                avatar: 'https://q9.itc.cn/q_70/images03/20240509/ed6fba708e1748e9a33e59be848515ee.jpeg',
                name: '张三',
                comment: '商品质量很好，非常满意！',
                rating: 5,
            },
            {
                avatar: 'https://q4.itc.cn/q_70/images03/20240521/47eb5d9a8b37454aaf2bc5d4e3c16c75.jpeg',
                name: '李四',
                comment: '发货速度很快，但包装有待改进。',
                rating: 4,
            },
        ],
    },
    {
        id:6,
        productName: '红米 K70 Pro',
        description: '小米新品手机',
        category: '2.1',
        price: 2626,
        stock: 60,
        views: 1500,
        sales: 400,
        parameters: ['购买类型: 蓝色 128G', '优惠券: 暂无', '促销活动: 暂无'],
        services: ['七天无理由退货' , '退货运费险'],
        reviews: 4.5,
        details: [
            'https://cdn.cnbj1.fds.api.mi-img.com/product-images/xiaomi14ghnegm/index/23234.png',
            'https://cdn.cnbj1.fds.api.mi-img.com/product-images/xiaomi14ghnegm/index/40717.png',
            'https://cdn.cnbj1.fds.api.mi-img.com/product-images/xiaomi14ghnegm/index/23203.png',
            'https://cdn.cnbj1.fds.api.mi-img.com/product-images/xiaomi14ghnegm/index/28955-2.png',
            'https://cdn.cnbj1.fds.api.mi-img.com/product-images/xiaomi14ghnegm/index/37138.png',
        ],
        userReviews: [
            {
                avatar: 'https://q9.itc.cn/q_70/images03/20240509/ed6fba708e1748e9a33e59be848515ee.jpeg',
                name: '张三',
                comment: '商品质量很好，非常满意！',
                rating: 5,
            },
            {
                avatar: 'https://q4.itc.cn/q_70/images03/20240521/47eb5d9a8b37454aaf2bc5d4e3c16c75.jpeg',
                name: '李四',
                comment: '发货速度很快，但包装有待改进。',
                rating: 4,
            },
        ],
    },
    {
        id:7,
        productName: '三星Galaxy X9手机',
        description: '这是一个手机，属于三星',
        category: '2.3',
        price: 4560,
        stock: 190,
        views: 1500,
        sales: 400,
        parameters: ['购买类型: 柔光白 256G', '优惠券: 暂无', '促销活动: 暂无'],
        services: ['七天无理由退货' , '退货运费险'],
        reviews: 4.5,
        details: [
            'https://cdn.cnbj1.fds.api.mi-img.com/product-images/xiaomi14ghnegm/index/23234.png',
            'https://cdn.cnbj1.fds.api.mi-img.com/product-images/xiaomi14ghnegm/index/40717.png',
            'https://cdn.cnbj1.fds.api.mi-img.com/product-images/xiaomi14ghnegm/index/23203.png',
            'https://cdn.cnbj1.fds.api.mi-img.com/product-images/xiaomi14ghnegm/index/28955-2.png',
            'https://cdn.cnbj1.fds.api.mi-img.com/product-images/xiaomi14ghnegm/index/37138.png',
        ],
        userReviews: [
            {
                avatar: 'https://q9.itc.cn/q_70/images03/20240509/ed6fba708e1748e9a33e59be848515ee.jpeg',
                name: '张三',
                comment: '商品质量很好，非常满意！',
                rating: 5,
            },
            {
                avatar: 'https://q4.itc.cn/q_70/images03/20240521/47eb5d9a8b37454aaf2bc5d4e3c16c75.jpeg',
                name: '李四',
                comment: '发货速度很快，但包装有待改进。',
                rating: 4,
            },
        ],
    },
    {
        id:8,
        productName: '佳能DSLR相机',
        description: '这是一个佳能相机',
        category: '1.1',
        price: 5000,
        stock: 500,
        views: 3000,
        sales: 700,
        parameters: ['购买类型: 白色 128G', '优惠券: 暂无', '促销活动: 暂无'],
        services: ['七天无理由退货' , '退货运费险'],
        reviews: 4.5,
        details: [
            'https://www.abesofmaine.com/files/AB/product/extra/large/canon_eos_rebel_t7_dslr_camera_with_18-55mm_lens_11048.jpg',
            'https://img0.baidu.com/it/u=1806138734,3187433811&fm=253&fmt=auto&app=138&f=JPEG?w=658&h=494',
            'https://2c.zol-img.com.cn/product/22_501x2000/4/ce6CR6kBKYkjU.jpg',
            'https://img0.baidu.com/it/u=2300930586,4156825790&fm=253&fmt=auto&app=138&f=JPEG?w=384&h=500',
            'https://img0.baidu.com/it/u=567319417,2126227736&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=341'
        ],
        userReviews: [
            {
                avatar: 'https://q9.itc.cn/q_70/images03/20240509/ed6fba708e1748e9a33e59be848515ee.jpeg',
                name: '张三',
                comment: '商品质量很好，非常满意！',
                rating: 5,
            },
            {
                avatar: 'https://q4.itc.cn/q_70/images03/20240521/47eb5d9a8b37454aaf2bc5d4e3c16c75.jpeg',
                name: '李四',
                comment: '发货速度很快，但包装有待改进。',
                rating: 4,
            },
        ],
    },
    {
        id:9,
        productName: '美的空调',
        description: '这是一个空调，属于美的',
        category: '3.5',
        price: 10000,
        stock: 70,
        views: 2000,
        sales: 200,
        parameters: ['购买类型: 白色', '优惠券: 暂无', '促销活动: 暂无'],
        services: ['七天无理由退货' , '退货运费险','一年保修期'],
        reviews: 4.5,
        details: [
            'https://cdn.cnbj1.fds.api.mi-img.com/product-images/xiaomi14ghnegm/index/23234.png',
            'https://cdn.cnbj1.fds.api.mi-img.com/product-images/xiaomi14ghnegm/index/40717.png',
            'https://cdn.cnbj1.fds.api.mi-img.com/product-images/xiaomi14ghnegm/index/23203.png',
            'https://cdn.cnbj1.fds.api.mi-img.com/product-images/xiaomi14ghnegm/index/28955-2.png',
            'https://cdn.cnbj1.fds.api.mi-img.com/product-images/xiaomi14ghnegm/index/37138.png',
        ],
        userReviews: [
            {
                avatar: 'https://q9.itc.cn/q_70/images03/20240509/ed6fba708e1748e9a33e59be848515ee.jpeg',
                name: '张三',
                comment: '商品质量很好，非常满意！',
                rating: 5,
            },
            {
                avatar: 'https://q4.itc.cn/q_70/images03/20240521/47eb5d9a8b37454aaf2bc5d4e3c16c75.jpeg',
                name: '李四',
                comment: '发货速度很快，但包装有待改进。',
                rating: 4,
            },
        ],
    },
    {
        id:10,
        productName: '电饭煲',
        description: '这是一个电饭煲',
        category: '3.6',
        price: 1500,
        stock: 20,
        views: 500,
        sales: 40,
        parameters: ['购买类型: 多功能款', '优惠券: 暂无', '促销活动: 暂无'],
        services: ['七天无理由退货' , '退货运费险'],
        reviews: 4.5,
        details: [
            'https://cdn.cnbj1.fds.api.mi-img.com/product-images/xiaomi14ghnegm/index/23234.png',
            'https://cdn.cnbj1.fds.api.mi-img.com/product-images/xiaomi14ghnegm/index/40717.png',
            'https://cdn.cnbj1.fds.api.mi-img.com/product-images/xiaomi14ghnegm/index/23203.png',
            'https://cdn.cnbj1.fds.api.mi-img.com/product-images/xiaomi14ghnegm/index/28955-2.png',
            'https://cdn.cnbj1.fds.api.mi-img.com/product-images/xiaomi14ghnegm/index/37138.png',
        ],
        userReviews: [
            {
                avatar: 'https://q9.itc.cn/q_70/images03/20240509/ed6fba708e1748e9a33e59be848515ee.jpeg',
                name: '张三',
                comment: '商品质量很好，非常满意！',
                rating: 5,
            },
            {
                avatar: 'https://q4.itc.cn/q_70/images03/20240521/47eb5d9a8b37454aaf2bc5d4e3c16c75.jpeg',
                name: '李四',
                comment: '发货速度很快，但包装有待改进。',
                rating: 4,
            },
        ],
    }
];
export const  initialProduct=[{
    id:1,
    productName: '小米xxxx手机',
    description: '这是一个手机，属于小米',
    category: '2.1',
    price: 2580,
    stock: 60,
    views: 1500,
    sales: 400,
    parameters: ['购买类型: 黑色 128G', '优惠券: 暂无', '促销活动: 暂无'],
    services: ['七天无理由退货' , '退货运费险'],
    reviews: 4.5,
    details: [
        'https://cdn.cnbj1.fds.api.mi-img.com/product-images/xiaomi14ghnegm/index/23234.png',
        'https://cdn.cnbj1.fds.api.mi-img.com/product-images/xiaomi14ghnegm/index/40717.png',
        'https://cdn.cnbj1.fds.api.mi-img.com/product-images/xiaomi14ghnegm/index/23203.png',
        'https://cdn.cnbj1.fds.api.mi-img.com/product-images/xiaomi14ghnegm/index/28955-2.png',
        'https://cdn.cnbj1.fds.api.mi-img.com/product-images/xiaomi14ghnegm/index/37138.png',
    ],
    userReviews: [
        {
            avatar: 'https://q9.itc.cn/q_70/images03/20240509/ed6fba708e1748e9a33e59be848515ee.jpeg',
            name: '张三',
            comment: '商品质量很好，非常满意！',
            rating: 5,
        },
        {
            avatar: 'https://q4.itc.cn/q_70/images03/20240521/47eb5d9a8b37454aaf2bc5d4e3c16c75.jpeg',
            name: '李四',
            comment: '发货速度很快，但包装有待改进。',
            rating: 4,
        },
    ],
    count: 1,
    isChecked:false
}];
export const loadProductList = ()=>{
    const productList = JSON.parse(localStorage.getItem("productList"));
    if(!productList){
        localStorage.setItem("productList", JSON.stringify(initialProductList));
        console.log("-----------------设置初始商品列表-----------------")
    }
};
export const loadProduct=()=>{
    const product = JSON.parse(localStorage.getItem("product"));
    if(!product){
        localStorage.setItem("product", JSON.stringify(initialProduct));
    }
};
export const loadShoppingCarProducts=()=>{
    const cart = JSON.parse(localStorage.getItem('cart'));
    if(!cart||cart.length===0){
        console.log("购物车为空");
        localStorage.setItem('cart',JSON.stringify([]));
    }
};